const http = {
	request: function( {url,method,data,header}) {
		return new Promise((resolve, reject) => {
			const token = uni.getStorageSync('token')
			const tempHeader = {
					'Content-Type':'application/json;charset=UTF-8',
					token
			}
			header = header == undefined ? tempHeader : header
			uni.request({
				url,
				data,
				header,
				method,
				dataType: 'json',
				success: (res) => {
					console.log({url,header,method,data},res.data);
	
					resolve(res.data)
				},
				fail: (res) => {
					uni.showToast({
						title: '网络错误',
						icon: "none"
					})
					reject(res)
				}
			})
		})
	}

}
export default http
